﻿@using CoralNode.Core.Entity.Enums
@using CoralNode.MvcClient.Helper
@using Coralcode.Utils.Basic
@model CoralNode.Core.Entity.Domains.Site.SiteExtendDomain

@{
    ViewBag.Title = "Create";
}
@Html.IncludePage("CoralAdmin/site", "_Left", new { current = "site" })
<!--content-->
<div id="pbody">
    <div class="extra">
        <div class="pbody_top">
            <span class="ico ico_setting_system"></span><span class="t t_c">系统设置&nbsp;&nbsp;/&nbsp;&nbsp;站点管理&nbsp;&nbsp;/&nbsp;&nbsp;扩展管理</span>
        </div>
        <div id="main">
            <div class="local">
                <a href="/m/site" class="ico ico_back btn"></a>
            </div>
            <div class="content_tab extra_normal">
                @Html.IncludePage("CoralAdmin/site", "_navtab", new { current = "extensionsetting", siteId = (int)ViewBag.SiteId })
            </div>
            <div class="content_tab extra_normal pl_26">
                <div class="tablist extra_normal js_field_tab">
                    @foreach (var item in @ViewBag.ExtendGroupList) {
                        <a data-groupid="@item.Id">@item.Title</a>
                    }
                </div>
                <div class="fun">
                    <a href="/m/site" class="ico ico_back btn f_r ml_3"></a>
                    <a href="#" class="btn_4" data-title="字段组管理" data-dialog=""
                        id="addTab">字段组管理</a>
                </div>
            </div>
            <div class="pt_3">
                <form id="spform" action="/m/site/settingSiteExtend?siteId=@ViewBag.siteId" method="POST">
                    @if (@ViewBag.Msg != null) {
                        <div class="error_msg">
                            @ViewBag.Msg.Msg
                        </div>
                    }
                    @Html.AntiForgeryToken()
                    @Html.ValidationSummary(true)
                    <div class="fieldContainer">
                        <div id="fieldManage" data-tabs="0" data-field="1">
                            <div class="js_tabcnt">
                                @foreach (var group in @ViewBag.ExtendGroupList) {
                                    <div class="table_form form_main" data-groupid="@group.Id">
                                        <table>
                                            <tbody>
                                                @foreach (var item in group.SiteExtendList) {
                                                    <tr itemid="@item.Id" data-type="@item.FieldType">
                                                        <th width="60"><span class="info_txt">@item.Title：</span></th>
                                                        <td>
                                                            @if (@item.FieldType == NodeEnums.BasicFieldType.TextField) {
                                                                <input class="text w_37" type="text" disabled="disabled" />
                                                            } else if (@item.FieldType == NodeEnums.BasicFieldType.TextArea) {
                                                                <textarea disabled="disabled" class="h_8 w_37"></textarea>
                                                            } else if (@item.FieldType == NodeEnums.BasicFieldType.PasswordField) {
                                                                <input class="text w_37" type="password" disabled="disabled" />
                                                            } else if (@item.FieldType == NodeEnums.BasicFieldType.FileField) {
                                                                <div class="field_file"></div>
                                                            } else if (@item.FieldType == NodeEnums.BasicFieldType.ImageField) {
                                                                <div class="field_pic"></div>
                                                            } else if (@item.FieldType == NodeEnums.BasicFieldType.MultiImage) {
                                                                <div class="field_pic"></div>
                                                                <div class="field_pic"></div>
                                                            } else {
                                                                <div class="field_editer">
                                                                    <div class="t"></div>
                                                                    <textarea disabled="disabled" class="h_8 w_37"></textarea>
                                                                </div>
                                                            }
                                                            <input name="fieldDomain" type="hidden" value='{"id":"@item.Id","refId":"@item.SiteId","page":"@group.Id","type":"@item.FieldType","remark":"@item.Title","name":"@item.FieldName","value":"@item.Value","tips":"@item.Hint","validate":"@item.Validator"}'>
                                                        </td>
                                                    </tr>
                                                }
                                            </tbody>
                                        </table>
                                    </div>
                                }
                            </div>
                            <div class="fieldtype" id="addField">
                                <ul class="clearfix">
                                    @foreach (var item in @ViewBag.FieldTypeList) {
                                        <li data-type="@item.Value">@item.Key</li>
                                    }
                                </ul>
                            </div>
                        </div>
                        <div id="fieldFrame">
                            <iframe name="fieldFrame" scrolling="auto" src="/Themes/CoralAdmin/_misc/field/fieldType_1.html"
                                frameborder="0"></iframe>
                            <div id="fieldOpt">
                                <a class="ico ico_copy" title="复制"></a><a class="ico ico_del"
                                    action="/m/site/DeleteSiteExtend/" title="删除"></a>
                            </div>
                        </div>

                        <div class="fun p_2">
                            <input class="btn_1" type="submit" value="提交保存">
                        </div>
                    </div>
                    <a id="triggerValidate"></a>
                    <input type="hidden" name="siteId" value="@ViewBag.siteId" id="refId" />
                </form>
            </div>
        </div>
    </div>
</div>
<!-- groupmanage -->
<div id="groupcontent">
    <ul class="list_tag d_GroupTabDialog " data-savehref="/m/site/saveSiteExtendGroup"
        data-delhref="/m/site/deleteSiteExtendGroup/" id="addTabDialog">
        @foreach (var item in @ViewBag.ExtendGroupList) {
            <li><span>@item.Title</span><input type="text" data-groupid="@item.Id" value="@item.Title"><i
                class="del"></i>
            </li>
        }
        <li class="add"><a class="btn_4">添 加</a></li>
    </ul>
</div>
<script src="/Themes/CoralAdmin/_misc/scripts/addField.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('.nav_left_style2').find('li').eq(0).addClass('current');
        $(".tabCnt tbody").sortable();
        $('.form_tabs a:first').addClass("current");
        var group = [];
        var ids = [];
        $('.form_tabs a:not(#addTab)').each(function () {
            group.push($(this).text());
            ids.push($(this).attr("itemId"));
        });
        $('#group_tabs').val(group);
        $('#group_tabs_id').val(ids);
    })
</script>
